#include "IconLabel.h"

#include <QtGui/QLabel>
#include <QtGui/QFocusEvent>
#include <QtCore/QDebug>

IconLabel::IconLabel(const QString &icon, const QString &iconHover, const QString &iconPressed) : 
                     m_iconString(icon),
                     m_iconHoverString(iconHover),
                     m_iconPressedString(iconPressed)
                    
{
    setMouseTracking(true);
    setFixedSize(20, 20);
    setScaledContents(true);
    setPixmap(QPixmap(m_iconString));
}

void IconLabel::enterEvent(QEvent *event)
{
    if(!m_iconString.isEmpty())
    {
        setPixmap(QPixmap(m_iconHoverString));
    }

    QLabel::enterEvent(event);
}

void IconLabel::mousePressEvent(QMouseEvent *event)
{
    if(!m_iconPressedString.isEmpty())
    {
        setPixmap(QPixmap(m_iconPressedString));
    }

    emit labelClicked();
    QLabel::mousePressEvent(event);
}

void IconLabel::leaveEvent(QEvent *event)
{
    if(!m_iconString.isEmpty())
    {
        setPixmap(QPixmap(m_iconString));
    }

    QLabel::leaveEvent(event);
}

